package com.songlanyun.common.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonValue;
import com.songlanyun.common.drive.IntegerEnum;

import java.util.Objects;

public class CommentConstant {

    /**
     * 评论类型
     * general ： 普通商品
     * service ： 服务商品
     * union_business ： 联盟商家订单
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum CommentType implements IntegerEnum<Integer> {

        GENERAL(0, "普通商品"),//普通商品

        SERVICE(1, "服务商品"),//服务商品

        UNION_BUSINESS(2, "联盟商家订单"),//联盟商家订单
        ;


        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        CommentType(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static CommentConstant.CommentType getByCode(int code) {
            for (CommentConstant.CommentType value : CommentConstant.CommentType.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }


    /**
     * 评论类型
     * 'opus' 作品，
     * ‘ARTICLE’ 文章，
     * ‘other’其它
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum CommentModelType implements IntegerEnum<Integer> {

        OPUS(0, "作品"),

        ARTICLE(1, "文章"),

        OTHER(2, "其它"),
        ;


        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        CommentModelType(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static CommentConstant.CommentModelType getByCode(int code) {
            for (CommentConstant.CommentModelType value : CommentConstant.CommentModelType.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }
}
